from anonymous_population import Population

""" Simulation of predetor-prey interaction; with lions, zebras and limited resources. """

zebraPopMax = 60   # maximum zebra population, imitates limited resources
zebraMeetsLion = 0  #initiate a point for the two populations to meet
chancesOfMeeting = 0.01 

class Zebra(Population):
    """ Zebra population as prey. """

    def birth(self):
        """ birth with restricted resources, i.e. max population """
        return (self.pop)*self.birthrate*(1-(self.pop/zebraPopMax))*self.timeStep

    def death(self):
        """ death by being eaten """
        return zebraMeetsLion*chancesOfMeeting*self.timeStep


class Lion(Population):
    """ Lion population as predetor. """

    def birth(self):
        """ normal birth increased if more prey eaten """
        return self.birthrate*self.pop*zebraMeetsLion*chancesOfMeeting*self.timeStep



zebras = Zebra(20, 0.1, 0.1, 0, 20, 0.001)
lions = Lion(10, 0.1, 0.5, 0, 20, 0.001)

for i in range(1,100000):
    zebraMeetsLion = zebras.pop*lions.pop
    zebras.setPop()
    lions.setPop()
        
zebras.plotPop()
lions.plotPop()


